﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RRHH.Entities;
using System.Data.SqlClient;
using System.Data;

namespace RRHH.DataAccess
{
    public class DAOEstadoCivil : IDAOBase<BEEstCivil, int>
    {
        public bool Update(BEEstCivil oPersonal)
        {
            throw new NotImplementedException();
        }

        public BEEstCivil Create(BEEstCivil oPersonal)
        {
            throw new NotImplementedException();
        }

        public BEEstCivil Get(int id)
        {
            throw new NotImplementedException();
        }

        public bool Delete(int id)
        {
            throw new NotImplementedException();
        }

        public List<BEEstCivil> List()
        {
            StringBuilder sqlBuilder = new StringBuilder();

            sqlBuilder.Append(" SELECT * FROM ESTADOCIVIL");

            string sql = sqlBuilder.ToString();

            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.CommandText = sql;

            using (DataAccess adoDataService = new DataAccess())
            {

                List<BEEstCivil> oEstadoList = new List<BEEstCivil>();
                IDataReader dr = adoDataService.ExecuteReader(sqlCommand);

                while (dr.Read())
                {
                    BEEstCivil oEstado = new BEEstCivil();
                    oEstado.IDESTADOCIVIL = Convert.ToString(dr["IDESTADOCIVIL"]);
                    oEstado.DESCRIPCION = Convert.ToString(dr["DESCRIPCION"]);

                    oEstadoList.Add(oEstado);
                }
                dr.Close();

                adoDataService.Dispose();

                return oEstadoList;
            }
        }
    }
}
